package com.dingding.order.processer;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.dingding.order.code.order.PublishCarType;
import com.dingding.order.processer.impl.NormalOrderProcesser;
import com.dingding.order.processer.impl.SpecialOrderProcesser;
import com.dingding.order.processer.impl.TaxiOrderProcesser;

/**
 * @Description:订单处理器的调度类
 * @author fengshuonan
 * @date 2016年8月18日 下午7:17:57
 * @version 叮叮搭车
 * @since 2.4
 */
@Component("processerFactory")
public class ProcesserFactory {

	@Resource(name = "normalOrderProcesser")
	NormalOrderProcesser normalOrderProcesser;
	
	@Resource(name = "taxiOrderProcesser")
	TaxiOrderProcesser taxiOrderProcesser;
	
	@Resource(name = "specialOrderProcesser")
	SpecialOrderProcesser specialOrderProcesser;
	
	/**
	 * @Description:根据订单类型获取对应订单类型的处理器
	 * @param orderType 1:私家车 2:出租车 3:专车
	 * @author fengshuonan
	 * @since 2.4
	 */
	public IOrderProcesser getOrderProcesser(int orderType){
		if(orderType == PublishCarType.SHUN_FENG_CHE.getCode()){
			return this.normalOrderProcesser;
		}else if(orderType == PublishCarType.TAXI.getCode()){
			return this.taxiOrderProcesser;
		}else if(orderType == PublishCarType.SPECIAL.getCode()){
			return this.specialOrderProcesser;
		}else{
			throw new RuntimeException("没有对应类型的订单处理器！");
		}
	}
	
	/**
	 * @Description:根据订单类型获取对应订单类型的处理器
	 * @param orderType 1:私家车 2:出租车 3:专车
	 * @author fengshuonan
	 * @since 2.4
	 */
	public IOrderProcesser getOrderProcesser(PublishCarType orderType){
		if(orderType == PublishCarType.SHUN_FENG_CHE){
			return this.normalOrderProcesser;
		}else if(orderType == PublishCarType.TAXI){
			return this.taxiOrderProcesser;
		}else if(orderType == PublishCarType.SPECIAL){
			return this.specialOrderProcesser;
		}else{
			throw new RuntimeException("没有对应类型的订单处理器！");
		}
	}
}
